package com.mdd.front.vo.leasing;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Objects;

@Data
@ApiModel("租赁方案详细列表Vo")
public class LeasingSchemeDetailsVo implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "编号")
    private Long id;

    @ApiModelProperty(value = "租赁类型:1、月 2、周 3、日")
    private Integer leaseType;

    @ApiModelProperty(value = "方案名称")
    private String name;

    @ApiModelProperty(value = "周期数")
    private Integer periodicity;

    @ApiModelProperty(value = "每期金额")
    private BigDecimal amountPeriod;

    @ApiModelProperty(value = "押金")
    private BigDecimal deposit;

    @ApiModelProperty(value = "免押金额")
    private BigDecimal exemptDeposit;

    @ApiModelProperty(value = "实际押金")
    private BigDecimal actualDeposit;

    @ApiModelProperty(value = "首付")
    private BigDecimal downPayments;

    @ApiModelProperty(value = "其他费用")
    private BigDecimal otherExpenses;

    @ApiModelProperty(value = "是否有违约金:0、没有违约金 1、有违约金")
    private Integer needDamages;

    @ApiModelProperty(value = "宽限违约天数")
    private Integer graceDays;

    @ApiModelProperty(value = "违约金比例;每逾期一天收取百分比，每期租金费用作为违约金（）")
    private String penaltyRatio;

    @ApiModelProperty(value = "租金字符串")
    private String amountStr;

    public String getAmountStr() {
        if(Objects.isNull(amountPeriod)){
            return  null;
        }
        amountStr =  amountPeriod.setScale(2, RoundingMode.HALF_DOWN).toString(); // 设置保留两位小数并舍入
        if(leaseType.equals(1)){
            amountStr = amountStr + "/月";
        }else  if(leaseType.equals(2)){
            amountStr = amountStr + "/周";
        }else  if(leaseType.equals(3)){
            amountStr = amountStr + "/日";
        }
        return amountStr;
    }
}
